let arr = [
    [1, 2, 2],
    [3, 4, 5, 5],
    [6, 7, 8, 9, [11, 12, [12, 13, [14]]]], 10
];

// var newArr=arr.toString().split(',').map(item=>Number(item))
// var newArr2=arr.flat(Infinity)
// console.log(newArr2)

// while (arr.some(item=>{return Array.isArray(item)})){
//     arr=[].concat(...arr)
//     console.log(arr)
// }
(function (){
    function myFlat(){
        var that=this
        var arr=[]
        function fn(that){
            for(var i=0;i<that.length;i++){
                var item=that[i]
                if(Array.isArray(item)){
                    fn(item)
                    continue
                }
                arr.push(item)
            }
        }
        fn(that)
        return arr
    }
    Array.prototype.myFlat=myFlat
})()

arr = arr.myFlat();
console.log(arr);
